package com.wzy.oa_sys.controller.schedule;


import com.wzy.oa_sys.model.request.schedule.BoardroomReq;
import com.wzy.oa_sys.model.request.schedule.UseBoardroomReq;
import com.wzy.oa_sys.model.response.schedule.BoardroomResp;
import com.wzy.oa_sys.model.response.schedule.ScheduleResp;
import com.wzy.oa_sys.service.schedule.BoardroomService;
import com.wzy.oa_sys.service.schedule.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/boardroom")
public class BoardroomController {

    @Autowired
    private BoardroomService boardroomService;

    @GetMapping("/list")
    public List<BoardroomResp> getBoardroomList() {
        return boardroomService.getBoardroomList();
    }

    @PostMapping("/addBoardroom")
    public void addBoardroom(@RequestBody BoardroomReq boardroomReq){
        System.out.println("新增会议室："+boardroomReq.toString());
        boardroomService.addBoardroom(boardroomReq);
    }

    @DeleteMapping("/deleteBoardroomById/{id}")
    public void deleteBoardroomById(@PathVariable("id") Integer id){
        System.out.println("删除会议室："+id);
        int i = boardroomService.deleteBoardroomById(id);
        System.out.println("删除结果："+i);
    }

    @PutMapping("/updateBoardroom")
    public void updateBoardroom(@RequestBody BoardroomReq boardroomReq){
        boardroomService.updateBoardroom(boardroomReq);
    }

    @PostMapping("/getICanUseBoardroomList")
    public List<BoardroomResp> getICanUseBoardroomList(@RequestBody UseBoardroomReq useBoardroomReq){
        useBoardroomReq.setStarttime(useBoardroomReq.getStarttime().plusHours(8));
        useBoardroomReq.setDeadline(useBoardroomReq.getDeadline().plusHours(8));
        System.out.println("开始检查会议室使用情况"+useBoardroomReq);
        List<BoardroomResp> iCanUseBoardroomList = boardroomService.getICanUseBoardroomList(useBoardroomReq);
        System.out.println("==================当前未被使用的会议室"+iCanUseBoardroomList);
        return iCanUseBoardroomList;
    }
}
